extends Button


func _ready():
	pass


func select_value(dialog_id):
	var list = DataSource.get_data_list(DataSource.drama)
	for i in range(list.size()):
		var item = list[i]
		if item["id"] == dialog_id:
			text = item["name"]
			cur_item_info = item
			hint_tooltip = text
			return
	
	_on_clear_button_up()
	

var cur_item_info

func _on_select_item(index, value):
	cur_item_info = DataSource.get_data_list(DataSource.drama)[index]
	hint_tooltip = text
	text = cur_item_info["name"]


func get_value():
	if cur_item_info:
		return cur_item_info["id"]
	else:
		return "-1"
		

func _on_DramaSelect_button_up():
	var ui = MainTool.getUILayer().add_ui("res://tool/common/PopUp/ListSearchPopup.tscn", 0, false)
	ui.popup_centered()
	ui.init_drama_items(funcref(self, "_on_select_item"))


func _on_clear_button_up():
	cur_item_info = null
	text = ""
	hint_tooltip = ""
